$(function () {
    $("#username").val(sessionStorage.getItem("username"));

});
layui.use(['form', 'layer', 'jquery', 'laydate'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer
            , laydate = layui.laydate;

        //自定义验证规则
        form.verify({});

        //监听提交
        form.on('submit(edit)',
            function (data) {
                data = data.field;
                //js 将数组转换位字符串
                console.log(data);
                data.id = sessionStorage.getItem("userId");
                //发异步，把数据提交给php
                $.ajax({
                    url: '/back/user/update',
                    data: data,
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        if (data.msg == 'success') {
                            layer.alert("修改密码成功", {
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();
                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        } else {
                            layer.msg("修改密码失败");
                        }

                    }
                });

                return false;
            });

    });